package com.seafood.entity;

import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.time.LocalDate;

/**
 * 溯源信息实体类
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "traceability")
public class Traceability extends BaseEntity {
    
    @NotBlank(message = "批次号不能为空")
    @Size(max = 100, message = "批次号长度不能超过100字符")
    @Column(name = "batch_number", unique = true, nullable = false, length = 100)
    private String batchNumber;
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "product_id", nullable = false)
    private Product product;
    
    @Column(name = "fishing_vessel", length = 100)
    private String fishingVessel;
    
    @Column(name = "fishing_location", length = 200)
    private String fishingLocation;
    
    @Column(name = "fishing_coordinates", length = 100)
    private String fishingCoordinates;
    
    @Column(name = "fishing_date")
    private LocalDate fishingDate;
    
    @Column(name = "fishing_method", length = 100)
    private String fishingMethod;
    
    @Column(name = "processing_facility", length = 200)
    private String processingFacility;
    
    @Column(name = "processing_date")
    private LocalDate processingDate;
    
    @Column(name = "freezing_method", length = 100)
    private String freezingMethod;
    
    @Column(name = "quality_certificate", length = 500)
    private String qualityCertificate;
    
    @Column(name = "inspection_report", length = 500)
    private String inspectionReport;
    
    @Column(name = "qr_code", length = 200)
    private String qrCode;
    
    @Column(name = "qr_code_url", length = 500)
    private String qrCodeUrl;
    
    @Column(name = "transport_company", length = 100)
    private String transportCompany;
    
    @Column(name = "transport_temperature", length = 50)
    private String transportTemperature;
}